<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\PositionLogic;
use Illuminate\Http\Request;

//职位管理
class PositionController extends Controller
{
    protected $logic;

    public function __construct()
    {
        $this->logic = new PositionLogic();
    }

    public function getPositionList(Request $request)
    {
        $rules = [
            'title'=>"present|nullable|string",
            'status'=>'present|nullable|in:0,1',
            'page'=>'required|numeric|min:1',
            'pagesize'=>'required|numeric|min:10',
        ];
        $this->verify($request->all(),$rules);

        try{

            $list = $this->logic->getPositionList($request->all());

            ret_json('ok','请求成功',$list);

        }catch (\Exception $e){
           ret_json('err',$e->getMessage());
        }
    }

    public function getMappingList(Request $request)
    {
        try {
            $rules = [
                'page' => 'required|numeric|min:1',
                'pagesize' => 'required|numeric|min:10',
            ];
            $this->verify($request->all(), $rules);

            $list = $this->logic->getMappingList($request->all());
            ret_json('ok','请求成功',$list);
        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }
}
